﻿@using SCMS.Resource
@model IEnumerable<SCMS.Model.FinanceLimit>
           
<!-- FINANCE LIMIT SETTINGS -->
<h4 style="text-align: center">@Resources.Approver_ViewFinanceLimits_FinanceLimitSettings.ToUpper()</h4>
<center>
    @if (UserContext.HasPermission(StandardPermissionProvider.ApproversManage))
    {                    
        @Ajax.ActionLink("[" + Resources.Global_String_AddNew + "]", "CreateFinanceLimit", new { id = "" }, new AjaxOptions
        {
            OnBegin = string.Format("ShowDialogue('{0}')", Resources.Approver_ViewFinanceLimits_NewFinanceLimit),
            UpdateTargetId = "popup-page",
            LoadingElementId = "popup-loading",
            Url = Url.Action("CreateFinanceLimit"),
            OnSuccess = "ClearForm();CenterPopup();"
        })
    }
</center>

<b style="font-weight: bold">&nbsp;&nbsp;@Resources.Approver_ViewFinanceLimits_FinanceLimits</b><br />
<i style="font-style: italic; font-size: 11px;">&nbsp;&nbsp;@Resources.Approver_ViewFinanceLimits_UnlimitedInstruction</i>
@if (Model.Count() > 0)
{    
    <table class="cardTable">
        <tr>
            <th width="20%">@Resources.Approver_FinanceLimitForm_FinanceLimitName</th><th width="20%">@Resources.Approver_FinanceLimitForm_MaximumAmount (@ViewBag.Currency)</th><th width="40%">@Resources.Global_String_Description</th>
            @if (UserContext.HasPermission(StandardPermissionProvider.ApproversManage))
            {                    
                <th width="20%">@Resources.Global_String_Manage</th>
            }
        </tr>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @item.Name
                </td>
                <td align="right">
                    @item.Limit.ToString("#,##0.00")
                </td>
                <td>
                    @item.Description
                </td>
                @if (UserContext.HasPermission(StandardPermissionProvider.ApproversManage))
                {                    
                    <td align="center">
                        @Ajax.ActionLink(Resources.Global_String_Edit, "EditFinanceLimit", new { id = "" }, new AjaxOptions
                        {
                            OnBegin = "ShowDialogue('" + item.Name + "')",
                            UpdateTargetId = "popup-page",
                            LoadingElementId = "popup-loading",
                            Url = Url.Action("EditFinanceLimit/" + item.Id),
                            OnSuccess = "CleanupFLimit();CenterPopup();"
                        }) &nbsp;|&nbsp;
                        @Ajax.ActionLink(Resources.Global_String_Delete, "DeleteFinanceLimit", new { id = "" }, new AjaxOptions
                        {
                            UpdateTargetId = "tabs-11",
                            LoadingElementId = "loading",
                            Url = Url.Action("DeleteFinanceLimit/" + item.Id),
                            Confirm = string.Format(Resources.Approver_ViewFinanceLimits_ConfirmDelete, item.Name)
                        })
                    </td>
                }
            </tr>
        }
    </table>
}

